package com.pda.gongpin.presenter;


import com.pda.gongpin.bean.MoveInBean;
import com.pda.gongpin.bean.MoveWareAreaBean;
import com.pda.gongpin.bean.StorageBinIdBean;
import com.pda.gongpin.bean.WareAreaBean;
import com.pda.gongpin.bean.request.ManualHandRequest;
import com.pda.gongpin.bean.request.StorageBinQueryRequest;
import com.pda.gongpin.bean.request.WareAreaQueryRequest;
import com.pda.gongpin.contract.FullMoveContract;
import com.pda.gongpin.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;

import com.wangshen.base.net.bean.BaseRowsAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import java.util.List;

import io.reactivex.functions.Consumer;

public class FullMovePresenter extends BasePresenter<FullMoveContract.View> implements FullMoveContract.Presenter {
    @Override
    public void wholePalletMove(String fromWareAreaId, String fromStorageBinId, String toWareAreaId, String toStorageBinId) {
        NetUtils.geApi().wholePalletMove(fromWareAreaId, fromStorageBinId, toWareAreaId, toStorageBinId)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseRowsAppEntity<List<MoveInBean>>>() {
                    @Override
                    public void accept(BaseRowsAppEntity<List<MoveInBean>> listBaseRowsAppEntity) throws Exception {
                        getView().onSuccess();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }

    @Override
    public void highWareAreaDropdownBox() {
        NetUtils.geApi().highWareAreaDropdownBox()
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<MoveWareAreaBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<MoveWareAreaBean>> listBaseRowsAppEntity) throws Exception {
                        getView().setWareList(listBaseRowsAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }

    @Override
    public void highStorageBinDropdownBox(String wareAreaId,boolean isTo) {
        NetUtils.geApi().highStorageBinDropdownBox(wareAreaId)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<String>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<String>> listBaseRowsAppEntity) throws Exception {
                        getView().setStorageList(listBaseRowsAppEntity.getData(),isTo);
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
